|
In programming jargon, Yoda conditions (also called ''Yoda notation'') is a programming style where the two parts of an expression are reversed from the typical order in a conditional statement. A yoda condition places the constant portion of the expression on the left side of the conditional statement. The name for this programming style is derived from the ''Star Wars'' character named Yoda, who spoke English in a non-standard syntax. Yoda conditions are part of the WordPress 〔https://make.wordpress.org/core/handbook/coding-standards/php/#yoda-conditions〕 and Symfony coding standards.〔http://symfony.com/doc/current/contributing/code/standards.html#structure〕 == Example == Usually a conditional statement would be written as: Yoda conditions describe the same expression, but reversed: The constant is written to the left of the comparison operator, and the variable whose value is being checked against the constant is written to the right. This order is comparable to the non-standard speaking style of Yoda, which is roughly object–subject–verb (e.g., “When nine hundred years old you reach, look as good you will not."). 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Yoda conditions」の詳細全文を読む スポンサード リンク
|